﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SDS.SPHealthAnalyzerRules.Delegation.Rules
{
    /// <summary>
    /// Ensure that the C3WTS config file includes the SharePoint service accounts (Excel + PerformancePoint)
    /// </summary>
    /// <remarks>
    /// SP default is to include the LOCAL group "WSS_WPG".
    /// 
    /// the config file is updated automatically when the SPService is started... restarting the SPService should rewrite the file
    /// </remarks>
    class C2WTS_AllowedCallers_Includes_SP
    {
        //TODO: implement verification of C2WTS configuration
        public void Check()
        {
            string RegKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Identity Foundation\Setup\v3.5";
            string RegName = "InstallPath";
            string RegValue = Microsoft.Win32.Registry.GetValue(RegKey, RegName, "") as string;
            //                c:\Program Files\Windows Identity Foundation\v3.5\c2wtshost.exe.config

            if (!String.IsNullOrEmpty(RegValue) &&
                System.IO.File.Exists(RegValue))
            {
                var cfg = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(
                    new System.Configuration.ExeConfigurationFileMap() { ExeConfigFilename = RegValue },
                    System.Configuration.ConfigurationUserLevel.None);

                //cfg.getse
            }
        } // Check()

    } // class
} // namespace
